<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>克隆优化节点操作</title>
</head>
<body>
    <p id="box1">old</p>
    <script>
        // 创建新节点时 : 先clone一个已有的节点, 再在clone节点上作修改
        for(var i = 0; i< 5; i++){
            var oP = document.createElement("p")
            oP.innerHTML = i
            document.body.appendChild(oP)
        }
        var oldP = document.getElementById('box1')
        for(var i = 0; i< 5; i++){
            var newP = oldP.cloneNode(false)
            newP.innerHTML = i
            document.body.appendChild(newP)
        }
        // Jsperf 查看运行速度
    </script>
</body>
</html>